// logs.js
const tool = require('../../utils/tool.js')
const util = require('../../utils/util.js')


Page({
  data: {
    page:1,
    size:100,
    data:[],
    total:0
  },
  async getData(){
    wx.showLoading({ mask:true,
      title: '请稍候',
    })
    let re = await tool.requestMethod("/consoleData",{
      page:this.data.page,
      size:this.data.size
    })
    wx.hideLoading()
    if(re.status==-2){
      tool.showToast('后端服务异常')
      return
    }
    this.setData({
      total:re.results.total
    })
    let re1 = this.data.data
    for(let i=0;i<re.results.data.length;i++){
      re1.push(re.results.data[i])
    }
    this.setData({
      data:re1
    })
  },
  back(){
    wx.navigateBack()
  },
  onLoad(options) {
    tool.setThemeColor(this)
    this.setData({
      sysImagURLPrefix:wx.getStorageSync('sysImagURLPrefix')
    })
    options = JSON.parse(options.data)
    this.setData({
      statusBarHeight: (parseInt(options.statusBarHeight.split('px')[0])).toString() + 'px',
      loginedUserInfo: options.loginedUserInfo,
      contentHeight: (parseInt(options.contentHeight.split('px')[0]) + 3).toString() + 'px',
      showPage:true,
      input: options.loginedUserInfo.name
    })
    this.getData()
  }
})
